/*
package com.xzp.bams.server;

import com.xzp.bams.entity.Account;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

*/
/**
 * @TODO
 * @Author xu
 * 2025/4/8
 *//*

public class BankServer {
    private static final int PORT = 8080;
    private static ExecutorService clientPool = Executors.newCachedThreadPool();
    private static Account accountManager = AccountManager.getInstance(); // 单例管理账户

    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(PORT)) {
            System.out.println("银行服务器正在启动，监听端口 " + PORT);

            while (true) {
                Socket clientSocket = serverSocket.accept();
                System.out.println("新连接来自 " + clientSocket.getInetAddress());
                clientPool.submit(() -> handleClient(clientSocket));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void handleClient(Socket clientSocket) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
             PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true)) {

            String request;
            while ((request = in.readLine()) != null) {
                System.out.println("接收到请求: " + request);
                String[] parts = request.split(",");

                if (parts[0].equalsIgnoreCase("LOGIN")) {
                    String username = parts[1]; // 假设用户名
                    String password = parts[2]; // 假设密码
                    if (accountManager.validateUser(username, password)) {
                        out.println("SUCCESS," + username); // 登录成功返回用户名
                    } else {
                        out.println("FAILURE,INVALID_CREDENTIALS"); // 登录失败
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                clientSocket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class AccountManager {
        public static Account getInstance() {
            return instance;
        }
    }
}
*/
